package com.tojabo.sort;

import org.junit.Test;

public class ShellSort {

	public void sort(int[] a){
		
		double len = a.length;
		int temp =0;
		
		while(true){
			len = Math.ceil(len/2);
			int d = (int) len;
			
			for(int x=0;x<d;x++){
				for(int i=x+d;i<a.length;i+=d){
					int j=i-d;
					temp = a[i];
					for(;j>=0&&temp<a[j];j-=d){
						a[j+d] = a[j];
					}
					a[j+d]=temp;
				}
			}
			
			if(d==1){
				break;
			}
		}
	}

	
}
